<template>
	<view>
	<view>aa测试群聊</view>
	<button @tap='goHome'>点击</button>
	</view>
</template>

<script>
	import app from '@/App.vue';
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js';
	export default {
		data() {
			return{
				end_count_limit:5,
				attr:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
				
			} 
		},
		methods: {
			goHome:function(){
				// this.common_msg_load(4);
				this.common_msg_load_one(4);
			},
			common_msg_load_all(already_num=4){
				var limit_count=uni.getStorageSync('msg_length');
				var msg_loading=uni.getStorageSync('msg_loading');
				if(msg_loading==0){
					console.log('limit_count',limit_count);
					var attr=this.attr;
					var end_count_limit=this.end_count_limit;
					var start_length_chu=attr.length;
					var start_length_end=attr.length-end_count_limit;
					var start_length_chu_true=attr.length;
					var storage_count=limit_count;
								
					start_length_end-=end_count_limit*storage_count;
					start_length_chu-=end_count_limit*storage_count;
					if(already_num){
						start_length_end-=already_num;
						start_length_chu-=already_num;
					}
					console.log('点击的start_length_end的值',start_length_end);
					console.log('点击的start_length_chu-的值',start_length_chu);
					console.log('点击的start_length_chu_true的值',start_length_chu_true);
					if(start_length_end<0){
						start_length_end=0;
					}
					console.log('attr',attr);
					var arr3=attr.slice(start_length_end,start_length_chu_true);
					var arr4=attr.slice(start_length_end,start_length_chu);
					console.log('arr4的值',arr4);
					console.log('arr3的值',arr3);
					/*当前截取的记录大于0，并且截取记录必须等于规定的条数*/
					if(arr4.length>0&&arr4.length==end_count_limit){
						limit_count+=1;
						uni.setStorageSync("msg_length",limit_count);
						console.log('有值',arr4);
					}else{
						uni.setStorageSync("msg_loading",1);
						console.log('无值',arr4);
					}
				}else{
					console.log('无值，不需再加载',arr4);
				}
			},
			common_msg_load_one(already_num=4){
				var limit_count=uni.getStorageSync('msg_length');
				var msg_loading=uni.getStorageSync('msg_loading');
				if(msg_loading==0){
					console.log('limit_count',limit_count);
					var attr=this.attr;
					var end_count_limit=this.end_count_limit;
					var start_length_chu=attr.length;
					var start_length_end=attr.length-end_count_limit;
					var start_length_chu_true=attr.length;
					var storage_count=limit_count;
								
					start_length_end-=end_count_limit*storage_count;
					start_length_chu-=end_count_limit*storage_count;
					if(already_num){
						start_length_end-=already_num;
						start_length_chu-=already_num;
					}
					console.log('点击的start_length_end的值',start_length_end);
					console.log('点击的start_length_chu-的值',start_length_chu);
					if(start_length_end<0){
						start_length_end=0;
					}
					console.log('attr',attr);
					var arr3=attr.slice(start_length_end,start_length_chu_true);
					var arr4=attr.slice(start_length_end,start_length_chu);
					var arr5=arr3.slice(0,-4);
					console.log('arr5的值',arr5);
					console.log('start_length_chu_true的值',start_length_chu_true);
					console.log('arr3的值',arr3);
					console.log('arr4的值',arr4);
					
					/*当前截取的记录大于0，并且截取记录必须等于规定的条数*/
					if(arr4.length>0&&arr4.length==end_count_limit){
						limit_count+=1;
						uni.setStorageSync("msg_length",limit_count);
						console.log('有值',arr4);
					}else{
						uni.setStorageSync("msg_loading",1);
						console.log('无值',arr4);
					}
				}else{
					console.log('无值，不需再加载',arr4);
				}
			},
		},
		onLoad(){
			/*初始化值*/
			uni.setStorageSync("msg_length",0);
			uni.setStorageSync("msg_loading",0);
			var attr=this.attr;
			
			var start_length_chu=attr.length;
			var start_length_end=attr.length-this.end_count_limit;
			console.log('attr',attr);
			
			console.log('1start_length_chu',start_length_chu);
			console.log('1start_length_end',start_length_end);
			var arr1=attr.slice(start_length_end,start_length_chu);
			
			start_length_end-=5;
			start_length_chu-=5;
			console.log('2start_length_chu',start_length_chu);
			console.log('2start_length_end',start_length_end);
			var arr2=attr.slice(start_length_end,start_length_chu);
			
			start_length_end-=5;
			start_length_chu-=5;
			console.log('3start_length_chu',start_length_chu);
			console.log('3start_length_end',start_length_end);
			var arr3=attr.slice(start_length_end,start_length_chu);
			
			
			
			start_length_end-=5;
			start_length_chu-=5;
			console.log('4start_length_chu',start_length_chu);
			console.log('4start_length_end',start_length_end);
			if(start_length_end<0){
				start_length_end=0;
			}
			var arr4=attr.slice(start_length_end,start_length_chu);
			
			
			
			console.log('arr1',arr1);
			console.log('arr2',arr2);
			console.log('arr3',arr3);
			console.log('arr4',arr4);
			// var arr=this.main_getGlobal();
			// gyzjModel.prototype.getIm(arr.token,arr.type).then(res=>{
			// 	console.log('res的值',res);
			// });
		}
		
	}
</script>

<style>
</style>
